//
//  ApiEnergyInfoManager.m
//  cocoapodText
//
//  Created by apple on 16/9/23.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "NetTool.h"
#import "AFNetworking.h"
#import "ApiEnergyInfoManager.h"


@interface ApiEnergyInfoManager()

@end
@implementation ApiEnergyInfoManager

//esCode=01&orgNo=520100000&structType=4&id=520100000:4

- (void)fsgy_api_energy_info_withRequestCode:(NSString *)code{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_analysis];
    NSDictionary *params=@{@"action":@"showTree",@"esCode":@"01",@"orgNo":@"520100000",@"structType":@"4",@"id":@"520100000:4"};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onEnergyInfo:result:code:)]){
            [_delegate onEnergyInfo:self result:responseObject code:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
    }];
}
- (void)fsgy_api_energy_info_withRequestCode:(NSString *)code esCode:(NSString *)esCode orgNo:(NSString *)orgNo structType:(NSString *)structType areaId:(NSString *)areaId{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_analysis];
    NSDictionary *params=@{@"action":@"showTree",@"esCode":esCode,@"orgNo":orgNo,@"structType":structType,@"id":areaId};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onEnergyInfo:result:code:)]){
            [_delegate onEnergyInfo:self result:responseObject code:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
    }];
}

- (void)fsgy_api_energy_info_withRequestCode:(NSString *)code esCode:(NSString *)esCode orgid:(NSString *)orgid structType:(NSString *)structType xslx:(NSString *)xslx startTime:(NSString *)startTime endTime:(NSString *)endTime{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_analysis];
    NSDictionary *params=@{@"action":@"showChart",@"esCode":esCode,@"orgid":orgid,@"structType":structType,@"xslx":xslx,@"startTime":startTime,@"endTime":endTime};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onEnergyInfo:result:code:)]){
            [_delegate onEnergyInfo:self result:responseObject code:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
    }];
}

- (void)fsgy_api_energy_benchmarking_info_withRequestCode:(NSString *)code{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_benchmarking];
    NSDictionary *params=@{@"action":@"showTree",@"esCode":@"01",@"orgNo":@"520100000",@"structType":@"4",@"id":@"520100000:4"};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onEnergyInfo:result:code:)]){
            [_delegate onEnergyInfo:self result:responseObject code:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
        if([_delegate respondsToSelector:@selector(onEnergyInfo:result:code:)]){
            [_delegate onEnergyInfo:self result:nil code:ECBError];
        }
    }];
}

- (void)fsgy_api_energy_benchmarking_info_withRequestCode:(NSString *)code esCode:(NSString *)esCode orgid:(NSString *)orgid structType:(NSString *)structType xslx:(NSString *)xslx startTime:(NSString *)startTime contrastType:(NSString *)contrastType contrastName:(NSString *)contrastName{
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    //申明返回的结果是json类型
    session.responseSerializer = [AFJSONResponseSerializer serializer];
    //如果报接受类型不一致请替换一致text/html或别的
    session.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSString *neturl=[NetTool fsgy_info_energy_benchmarking];
    NSDictionary *params=@{@"action":@"showChart",@"esCode":esCode,@"orgid":orgid,@"structType":structType,@"xslx":xslx,@"startTime":startTime,@"contrastType":contrastType,@"contrastName":contrastName};
    [session GET:neturl parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if([_delegate respondsToSelector:@selector(onEnergyInfo:result:code:)]){
            [_delegate onEnergyInfo:self result:responseObject code:code];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [CommonTool isSessionExpired:task];
        if([_delegate respondsToSelector:@selector(onEnergyInfo:result:code:)]){
            [_delegate onEnergyInfo:self result:nil code:ECBError];
        }
    }];
}

-(void)fsgy_api_energy_benchmarking_info_withRequestCode:(NSString *)code esCode:(NSString *)esCode orgNo:(NSString *)orgNo structType:(NSString *)structType areaId:(NSString *)areaId{

}
@end
